package com.ang.demo;

import com.ang.service1.TestService1;
import com.ang.service2.Config2;
import com.ang.service2.TestService2;
import com.ang.service3.TestService3;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestDemo {
    public static void main(String[] args) {
        /**
         * 编程式事务
         */
//        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
//        TestService t = ctx.getBean(TestService.class);
//
//        t.test1();

        /**
         * xml声明式事务
         */
//        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext1.xml");
//        TestService1 t = ctx.getBean(TestService1.class);
//
//        t.test1();

        /**
         * javaBean声明式事务
         */
//        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Config2.class);
//        TestService2 t = ctx.getBean(TestService2.class);
//
//        t.test1();

        /**
         * xml+javaBean，声明式事务
         */
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext3.xml");
        TestService3 t = ctx.getBean(TestService3.class);

        t.test1();
    }
}
